<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 1. str.startsWith()
        // 语法：startsWith(searchString, position)
        // 作用：判断是否以某个字符串开头
        // searchString:  要搜索的字符串
        // position    :  在str中开始搜索的位置，默认为0  可选
        // 返回值  true / false

        const str = "To be, or not to be, that is the question.";
        console.log(str.startsWith("To be")); // true
        console.log(str.startsWith("not to be")); // false
        console.log(str.startsWith("not to be", 10)); // true


        // 2. str.includes(substr[, pos])

        // 作用：判断一个字符串是否包含另一个子串   true / false
        const str2 = "To be, or not to be, that is the question.";
        console.log(str2.includes('not to be'))
    </script>
</body>

</html>